class Solution
{
public:
    vector<int> missingRolls(vector<int> &rolls, int mean, int n)
    {
        int m = rolls.size();
        int totalSum = (m + n) * mean;
        int observedSum = accumulate(rolls.begin(), rolls.end(), 0);
        int remainSum = totalSum - observedSum;
        // 只需n个点数之和为remainSum
        if (remainSum > 6 * n || remainSum < n)
        {
            return {};
        }
        if (remainSum / n == 0)
        {
            return vector<int>(n, remainSum / n);
        }
        int averagePointLow = remainSum / n;
        int averagePointHighCount = remainSum % n;
        vector<int> result(n, averagePointLow);
        fill(result.begin(), result.begin() + averagePointHighCount, averagePointLow + 1);
        return result;
    }
};